package com.blankii.androidlibrary.base

import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import com.blankii.androidlibrary.exts.logi

/**
 * author: blankii
 * created on: 2024/4/12 11:08
 * description:可以打印继承 baseActivity以及baseFragment 的生命周期
 */
class LifecycleObserver(private val className: String) : DefaultLifecycleObserver {

    private val TAG = "生命周期:$className"
    override fun onCreate(owner: LifecycleOwner) {
        super.onCreate(owner)
        "onCreate".logi(TAG)
    }

    override fun onStart(owner: LifecycleOwner) {
        super.onStart(owner)
        "onStart".logi(TAG)
    }

    override fun onResume(owner: LifecycleOwner) {
        super.onResume(owner)
        "onResume".logi(TAG)
    }

    override fun onPause(owner: LifecycleOwner) {
        super.onPause(owner)
        "onPause".logi(TAG)
    }

    override fun onStop(owner: LifecycleOwner) {
        super.onStop(owner)
        "onStop".logi(TAG)
    }

    override fun onDestroy(owner: LifecycleOwner) {
        super.onDestroy(owner)
        "onDestroy".logi(TAG)
    }
}